<div class="bjui-pageHeader">
    <form id="pagerForm" data-toggle="ajaxsearch" action="${request.getContextPath()}/ScrapSummary/scrapSummary" method="post">
        <div class="bjui-searchBar">
            <g:hiddenField name="SYS_QUERY_NAME" value="scrapSummary" />
            <g:hiddenField name="EXPORT_CONTENT_NAME" value="Excel" />
            <label>时间段：</label>
            <input type="text" name="startTime" value="${startTime}" data-pattern="yyyy-MM-dd" size="12" data-toggle="datepicker" placeholder="FROM">
            <input type="text" name="endTime" value="${endTime}" data-pattern="yyyy-MM-dd" size="12" data-toggle="datepicker" placeholder="TO">&nbsp;
            <label>存货编码：</label>
            <input type="text" name="partName" value="${partName}" size="17" placeholder="存货编码"/>&nbsp;

            <label>生产订单号：</label>
            <input type="text" name="lineId" value="${lineId}" size="17" placeholder="生产订单号"/>&nbsp;
            <label>所属部门：</label>
            <g:select name="department" from="${scrapSummaryDepartment}" data-toggle="selectpicker" data-live-search="true"
                      optionKey="department" optionValue="department" value="${department}" data-width="130" noSelection="['':'-- All --']" />
            <br /><br />
            <label>工序编码/名称：</label>
            <g:select name="step" from="${scrapSummaryStep}" data-toggle="selectpicker" data-live-search="true"
                  optionKey="step" optionValue="step" value="${step}" data-width="130" noSelection="['':'-- All --']" />&nbsp;
            <label>报废人：</label>
            <input type="text" name="user" value="${user}" size="17" placeholder="报废人"/>&nbsp;

            <label>报废属性：</label>
            <g:select name="scrapAttribute" from="${scrapSummaryScrapAttribute}" data-toggle="selectpicker" data-live-search="true"
                      optionKey="description" optionValue="description" value="${scrapAttribute}" data-width="130" multiple="multiple" noSelection="['':'-- All --']" />&nbsp;
            <label>是否追加：</label>
            <g:select name="readd" from="${scrapSummaryReAdd}" data-toggle="selectpicker" data-live-search="true"
                      optionKey="KEY" optionValue="VALUE" data-width="130" value="${readd}" noSelection="['':'-- All --']" />&nbsp;
            <label>订单状态：</label>
            <g:select name="startedState" from="${orderStatusAnalysisStartedList}" data-toggle="selectpicker" data-live-search="true"
                      optionKey="DOC_STATUS" optionValue="doc_state" data-width="130" value="${startedState}" noSelection="['':'-- All --']" />
            <br /><br />
            <button type="submit" class="btn-default" data-icon="search">查询</button>&nbsp;
            %{--<button type="button" class="btn-blue" onclick="javascript:bjuiExportExl('#pagerForm','${request.getContextPath()}/StageWip/exportExcel')"--}%
                    %{--data-icon="file-excel-o" title="导出Excel">导出</button>--}%
            <button type="button" class="btn-blue"
                    onclick="javascript:bjuiExportExl('#pagerForm','${request.getContextPath()}/ScrapSummary/exportExcel')"
                    data-icon="file-excel-o" title="导出Excel">导出</button>
        </div>
    </form>
</div>

<div class="panel-body">
    <div style="mini-width:400px;height:450px;" id="cellGlassOutputDiv"></div>
</div>

<div class="bjui-pageContent tableContent">
    <g:if test="${scrapSummary.size() > 0}">
        <table  data-toggle="tablefixed" data-width="100%" data-nowrap="true">
            <thead>
            <tr id="t1">
                <g:each in="${tableHeadList}" status="j" var="headInstance">
                    <g:if test="${headInstance!='RN'}">
                        <th width="150"><g:message code="${headInstance}" default="${headInstance}"/></th>
                    </g:if>
                </g:each>
            </tr>
            </thead>
            <tbody>
            <g:if test="${scrapSummary.size()>0}">
                <g:each in="${scrapSummary}" status="i" var="dataInstance">
                    <tr>
                        <g:each in="${tableHeadList}" status="j" var="headInstance">
                            <g:if test="${headInstance=='MAIN_QTY'&&headInstance!='RN'}">
                                <td name="SCRAPSUM${i}">${dataInstance["${headInstance}"]}</td>
                            </g:if>
                            <g:elseif test="${headInstance!='RN'}">
                                <td>${dataInstance["${headInstance}"]}</td>
                            </g:elseif>
                        </g:each>
                    </tr>
                </g:each>
                <tr>
                    <td colspan="13">小计</td>
                    <td name="scrapSumShow"></td>
                </tr>
                <tr>
                    <td colspan="13">合计</td>
                    <td>${scrapSummarySumQty.SUM_QTY[0]}</td>
                </tr>
            </g:if>
            </tbody>
        </table>
    </g:if>
    <g:else>
        <g:render template="../template/emptyPanel" />
    </g:else>
</div>
<g:render template="../template/51pagination" />
<script>
    $(function(){
        var scrapSumQty=0;
        for(var i=0;i<${scrapSummary.size()};i++){
            var scrapsumqty='SCRAPSUM'+i
            var scrapSumAdd=$("td[name='"+scrapsumqty+"']").text()==''?0:parseInt($("td[name='"+scrapsumqty+"']").text())
            scrapSumQty+=scrapSumAdd
        }
        $("td[name='scrapSumShow']").html(scrapSumQty)

    })
</script>